﻿using Core.MemCache;

namespace Core
{
    public class MemCacheComponent : Core.Component, IAwake
    {
        private Container container;

        public void Awake()
        {
            container = ReferencePool.Acquire<Container>();
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();

            ReferencePool.Recycle(container);
            container = null;
        }


        public int Count => container.Count;

        public bool Contains<T>(T value)
        {
            return container.Contains(value);
        }

        public bool ContainsExcept<T>(T value)
        {
            return container.ContainsExcept(value);
        }

        public void Add<T>(T value)
        {
            container.Add(value);
            //log.err($"MemcacheComponent.Add value={value} cnt={container.Count}");
        }

        public void Remove<T>(T value)
        {
            container.Remove(value);
            //log.err($"MemcacheComponent.Remove value={value} cnt={container.Count}");
        }
    }
}
